<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }

        .left li {
            display: block;
            margin-bottom: 20px;
            padding: 3px 10px;
        }

        .left li:hover {
            background-color: cornflowerblue;
            font-weight: bold;
            border-radius: 0 40% 40% 0;
        }

        .left li:active {
            background-color: rgba(100,149,237,.7);
            border-radius: 0 40% 40% 0;
        }

        .left a {
            display: inline-block;
            height: 50px;
            border: none;
            text-decoration: none;
            color: black;
            font-weight: bold;
            line-height: 50px;
        }

        .left a:hover {
            color: white;
        }

        .left a.active {
            border-bottom: 2px solid cornflowerblue;
        }

        body {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="left">
    <ul>
        <li><a th:href="@{/user/add}" target="right">新建用户</a></li>
        <li><a th:href="@{/user}" target="right">查看所有用户</a></li>
        <li><a href="/addliuyan" target="right">新增留言</a></li>
        <li><a href="/listliuyan" target="right">查看所有留言</a></li>
        <li><a>登录</a></li>
    </ul>
</div>
</body>
<script>
    const ul = document.querySelector('.left ul')
    ul.addEventListener('click', function (e) {
        if (e.target.tagName === "A") {
            const element = document.querySelector('.left ul a.active')
            if (element != null) {
                element.classList.remove('active')
            }
            e.target.classList.add('active')
        }
    })
</script>
</html>
